<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>包厢管理</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  	<script>
  		//全选
	function checkedAll(t) { 
		$("input[name='sellCheckBox']").each(function(i,item){
			 item.checked = t.checked;
		}); 
	} 
  	//审核通过和不通过
	function auditBox(status) {
		var boxIds = ""; 
		$("input[name='sellCheckBox']").each(function(i,item){
			 if (item.checked == true) {
				 boxIds += item.value + ",";
			 }
		});
		 
		if (boxIds == "") {
			alert("请选择要审核的餐厅!");
			return;
		}
		boxIds = boxIds.substring(0, boxIds.length-1);
		var dt = new Date();
		$.ajax( {
			type : "POST",
			url : "box!audit.html",
			data : "boxIds="+boxIds+"&status="+status+"&date=" + dt,
			success : function(data) {
				if ($.trim(data) == 0) {
					if (status == 1) { 
						alert('审核通过成功!');
					}
					if (status == 2) {
						alert('审核不通过成功');
					}
					document.location.reload();
				} else {
					alert('操作失败!');
				}
			}
		}); 
	} 
  	</script>
  </head>
  
  <body>
  	<form action="box!boxList.html" method="post" id="frmMealBox">
		包厢管理
		<hr/>
		<table width="100%">
			<tr>
				<td>包厢名称</td>
				<td><input type="text" name="name"/></td>  
				<td><input type="button" value="搜索" onclick="javascript:btnSelectBox();"/></td>
				<td style="text-align: right;">
					<a href="javascript:;" onclick="auditBox(1)">审核通过</a>	|
					<a href="javascript:;" onclick="auditBox(2)">审核不通过</a>		    
				</td>
			</tr>
		</table>

		<table width="100%" border="1">
			<tr>
				<td rowspan="1" ><input type="checkbox" name="sellCheckBoxAll" onclick="checkedAll(this)"/></td>
				<td>包厢名称</td> 
				<td>图片</td>
				<td>容纳人数</td>
				<td>最低消费</td>
				<td>备注</td>
				<td>审核状态</td>
				<td>状态</td>
			</tr>
			<s:iterator value="boxList">
				<tr>
					<td>
						<input type="checkbox" name="sellCheckBox" value="${id }"/>
					</td>
					<td>
						${name }
					</td> 
					<td>
						<img src="${webUrl }${images }" />
					</td>
					<td>
						${peopleNumber }
					</td>
					<td>
						${lowConsume }
					</td>
					<td>
						${remark }
					</td>
					<td>
						<s:if test="auditStatus == 0">
							审核中
						</s:if>
						<s:if test="auditStatus == 1">
							审核通过
						</s:if>
						<s:if test="auditStatus == 2">
							审核不通过
						</s:if>
					</td>
					<td> 
						<s:if test="status == 0">
							空闲
						</s:if>
						<s:if test="status == 1">
							已预订
						</s:if>
						<s:if test="status == 2">
							作废
						</s:if>
					</td>
				</tr>
			</s:iterator>
		</table>
		<div>
			<jsp:include page="../include/page.jsp"></jsp:include> 
		</div>
	</form>
     
  </body>
</html>
<script type="text/javascript">
	function btnSelectBox(){
		$("#frmMealBox").submit();
	}
</script>